var csInterface = new CSInterface();

// 个人主页
var homePageElement = document.querySelector("#homePage");
homePageElement.addEventListener("click", callHomepage);

function callHomepage() {
  window.cep.util.openURLInDefaultBrowser('https://gitee.com/brzjomo');
}

// 替换文本
var replaceButton = document.querySelector("#btn-replace");
replaceButton.addEventListener("click", replaceText);

function replaceText() {
  // 获取查找文本和替换文本
  var searchText = document.getElementsByName("search-text")[0].value;
  var replaceText = document.getElementsByName("replace-text")[0].value;
  
  // 如果查找文本为空，提示用户
  if (searchText === "") {
    alert("请输入要查找的文本!");
    return;
  }
  
  // csInterface.evalScript("textReplace(" + '"' + searchText + ", " + replaceText + '"' + ")");
  csInterface.evalScript("textReplace(" + JSON.stringify(searchText) + ", " + JSON.stringify(replaceText) + ")");
}